/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * FrameUtama.java
 *
 * Created on Dec 3, 2010, 9:32:24 PM
 */

package edu.unindra.company.gui;

import javax.swing.JLabel;
import javax.swing.JOptionPane;

import edu.unindra.company.template.ButtonTransparan;
import edu.unindra.company.template.PanelBackGround;
import edu.unindra.company.template.PanelTransparan;

import javax.swing.GroupLayout.Alignment;
import javax.swing.GroupLayout;

import java.awt.Font;
import java.awt.Color;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import javax.swing.ImageIcon;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

import javax.swing.LayoutStyle.ComponentPlacement;

import usu.widget.Button;

import javax.swing.SwingConstants;

/**
 * 
 * @author fendi
 */
@SuppressWarnings("serial")
public class FormUtama extends javax.swing.JFrame {

	@SuppressWarnings("unused")
	private ExecutorService executor;

	private ButtonTransparan btnAdd;
	private ButtonTransparan btnHome;
	private ButtonTransparan btnPrint;
	private ButtonTransparan btnExit;
	private ButtonTransparan btnReport;
	private Button btnLogo;

	private JLabel jLbl1;
	private JLabel jLbl2;

	private PanelBackGround panelBackground;
	private PanelTransparan panelTransparan;

	private FormMainEmployee mainEmployee;
	@SuppressWarnings("unused")
	private FormMainEmployeeAdd mainEmployeeAdd;
	@SuppressWarnings("unused")
	private FormMainIDCard mainIdCard;

	@SuppressWarnings("unused")
	private FormMainReport mainReport;

	/** Creates new form FrameUtama */
	public FormUtama() {
		executor = Executors.newCachedThreadPool();

		initComponents();
		setSize(800, 500);
		setLocationRelativeTo(null);

		vis();

		getGlassPane().setVisible(false);
		getGlassPane().setVisible(true);
		this.setResizable(false);

		vus();

		initActions();

	}

	private void initActions() {
		btnHome.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent arg0) {
				vus();

				setGlassPane(new FormMainEmployee());
				getGlassPane().setVisible(false);

				setGlassPane(new FormMainIDCard());
				getGlassPane().setVisible(false);

			}
		});

		btnAdd.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent arg0) {
				vis();
				setGlassPane(new FormMainEmployee());
				getGlassPane().setVisible(false);
				getGlassPane().setVisible(true);

			}
		});

		btnPrint.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent arg0) {
				vis();

				setGlassPane(new FormMainIDCard());
				getGlassPane().setVisible(false);
				getGlassPane().setVisible(true);

			}
		});

		btnPrint.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent arg0) {
				vis();

				setGlassPane(new FormMainIDCard());
				getGlassPane().setVisible(false);
				getGlassPane().setVisible(true);

			}
		});

		btnReport.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent arg0) {
				vis();

				setGlassPane(new FormMainReport());
				getGlassPane().setVisible(false);
				getGlassPane().setVisible(true);

			}
		});

		mainEmployee.getBtnAdd().addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent arg0) {

				System.out.println("test tambah");
				vis();

				setGlassPane(new FormMainEmployeeAdd());
				getGlassPane().setVisible(false);
				getGlassPane().setVisible(true);

			}
		});

	}

	void setStatus(boolean stus) {
		btnAdd.setEnabled(stus);
		btnPrint.setEnabled(stus);
		btnExit.setEnabled(stus);
	}

	void vus() {
		jLbl1.setVisible(true);
		jLbl2.setVisible(true);
		btnLogo.setVisible(true);
	}

	void vis() {
		jLbl1.setVisible(false);
		jLbl2.setVisible(false);
		btnLogo.setVisible(false);
	}

	/**
	 * This method is called from within the constructor to initialize the form.
	 * WARNING: Do NOT modify this code. The content of this method is always
	 * regenerated by the Form Editor.
	 */
	private void initComponents() {

		mainEmployee = new FormMainEmployee();
		mainEmployeeAdd = new FormMainEmployeeAdd();
		mainIdCard = new FormMainIDCard();
		mainReport = new FormMainReport();

		panelBackground = new PanelBackGround();
		panelTransparan = new PanelTransparan();

		btnAdd = new ButtonTransparan();
		btnAdd.setFont(new Font("Tahoma", Font.BOLD, 11));
		btnAdd.setText("Data Karyawan");
		btnHome = new ButtonTransparan();
		btnHome.setBackground(Color.BLACK);
		btnHome.setFont(new Font("Tahoma", Font.BOLD, 11));
		btnHome.setText("Home");
		btnHome.setVerticalAlignment(SwingConstants.BOTTOM);
		btnPrint = new ButtonTransparan();
		btnPrint.setFont(new Font("Tahoma", Font.BOLD, 11));
		btnPrint.setText("Id Card");
		btnExit = new ButtonTransparan();
		btnExit.setFont(new Font("Tahoma", Font.BOLD, 11));
		btnExit.setText("Keluar");

		btnLogo = new Button();
		btnLogo.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
			}
		});

		jLbl1 = new JLabel();

		jLbl2 = new JLabel();

		setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

		panelBackground.setLayout(new java.awt.BorderLayout());
		panelTransparan.setBackground(new java.awt.Color(0, 0, 0));

		btnAdd.setIcon(new javax.swing.ImageIcon(getClass().getResource(
				"/edu/unindra/company/image/addd.png"))); // NOI18N
		btnAdd.setToolTipText("Data Karyawan");
		btnAdd.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));

		btnHome.setIcon(new ImageIcon(FormUtama.class
				.getResource("/edu/unindra/company/image/home3.png"))); // NOI18N
		btnHome.setToolTipText("Home");
		btnHome.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));

		btnPrint.setIcon(new javax.swing.ImageIcon(getClass().getResource(
				"/edu/unindra/company/image/searc.png"))); // NOI18N
		btnPrint.setToolTipText("Id Card");
		btnPrint.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));

		btnExit.setIcon(new javax.swing.ImageIcon(getClass().getResource(
				"/edu/unindra/company/image/Exit.png"))); // NOI18N
		btnExit.setToolTipText("Keluar");
		btnExit.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
		btnExit.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				btnExitActionPerformed(evt);
			}
		});

		btnLogo.setIcon(new ImageIcon(FormUtama.class
				.getResource("/edu/unindra/company/image/logo_cv1.png")));

		jLbl1.setFont(new Font("Tahoma", Font.BOLD, 26));
		jLbl1.setForeground(Color.BLACK);
		jLbl1.setText("SELAMAT DATANG");

		jLbl2.setFont(new Font("Tahoma", Font.BOLD, 38));
		jLbl2.setForeground(Color.BLACK);
		jLbl2.setText("IDCARD APLIKASI");

		btnReport = new ButtonTransparan();
		btnReport.setIcon(new ImageIcon(FormUtama.class
				.getResource("/edu/unindra/company/image/kind.png")));
		btnReport.setToolTipText("Report");
		btnReport.setText("Report");
		btnReport.setFont(new Font("Tahoma", Font.BOLD, 11));

		javax.swing.GroupLayout panelTransparan2Layout = new javax.swing.GroupLayout(
				panelTransparan);
		panelTransparan2Layout
				.setHorizontalGroup(panelTransparan2Layout
						.createParallelGroup(Alignment.LEADING)
						.addGroup(
								panelTransparan2Layout
										.createSequentialGroup()
										.addContainerGap()
										.addGroup(
												panelTransparan2Layout
														.createParallelGroup(
																Alignment.LEADING)
														.addGroup(
																panelTransparan2Layout
																		.createSequentialGroup()
																		.addComponent(
																				btnHome,
																				GroupLayout.PREFERRED_SIZE,
																				134,
																				GroupLayout.PREFERRED_SIZE)
																		.addPreferredGap(
																				ComponentPlacement.RELATED)
																		.addComponent(
																				btnAdd,
																				GroupLayout.PREFERRED_SIZE,
																				164,
																				GroupLayout.PREFERRED_SIZE)
																		.addPreferredGap(
																				ComponentPlacement.RELATED)
																		.addComponent(
																				btnPrint,
																				GroupLayout.PREFERRED_SIZE,
																				131,
																				GroupLayout.PREFERRED_SIZE)
																		.addPreferredGap(
																				ComponentPlacement.RELATED)
																		.addComponent(
																				btnReport,
																				GroupLayout.PREFERRED_SIZE,
																				164,
																				GroupLayout.PREFERRED_SIZE)
																		.addPreferredGap(
																				ComponentPlacement.RELATED)
																		.addComponent(
																				btnExit,
																				GroupLayout.PREFERRED_SIZE,
																				GroupLayout.DEFAULT_SIZE,
																				GroupLayout.PREFERRED_SIZE))
														.addGroup(
																panelTransparan2Layout
																		.createSequentialGroup()
																		.addGap(22)
																		.addComponent(
																				btnLogo,
																				GroupLayout.PREFERRED_SIZE,
																				336,
																				GroupLayout.PREFERRED_SIZE)
																		.addGap(36)
																		.addGroup(
																				panelTransparan2Layout
																						.createParallelGroup(
																								Alignment.LEADING)
																						.addComponent(
																								jLbl1)
																						.addComponent(
																								jLbl2))))
										.addContainerGap(511, Short.MAX_VALUE)));
		panelTransparan2Layout
				.setVerticalGroup(panelTransparan2Layout
						.createParallelGroup(Alignment.LEADING)
						.addGroup(
								panelTransparan2Layout
										.createSequentialGroup()
										.addContainerGap()
										.addGroup(
												panelTransparan2Layout
														.createParallelGroup(
																Alignment.TRAILING)
														.addComponent(
																btnHome,
																GroupLayout.PREFERRED_SIZE,
																81,
																GroupLayout.PREFERRED_SIZE)
														.addGroup(
																panelTransparan2Layout
																		.createParallelGroup(
																				Alignment.BASELINE)
																		.addComponent(
																				btnAdd,
																				GroupLayout.PREFERRED_SIZE,
																				81,
																				GroupLayout.PREFERRED_SIZE)
																		.addComponent(
																				btnPrint,
																				GroupLayout.PREFERRED_SIZE,
																				81,
																				GroupLayout.PREFERRED_SIZE)
																		.addComponent(
																				btnExit,
																				GroupLayout.PREFERRED_SIZE,
																				81,
																				GroupLayout.PREFERRED_SIZE))
														.addComponent(
																btnReport,
																GroupLayout.PREFERRED_SIZE,
																81,
																GroupLayout.PREFERRED_SIZE))
										.addPreferredGap(
												ComponentPlacement.RELATED)
										.addGroup(
												panelTransparan2Layout
														.createParallelGroup(
																Alignment.LEADING)
														.addGroup(
																panelTransparan2Layout
																		.createSequentialGroup()
																		.addGap(109)
																		.addComponent(
																				jLbl1)
																		.addPreferredGap(
																				ComponentPlacement.RELATED)
																		.addComponent(
																				jLbl2,
																				GroupLayout.PREFERRED_SIZE,
																				86,
																				GroupLayout.PREFERRED_SIZE))
														.addGroup(
																panelTransparan2Layout
																		.createSequentialGroup()
																		.addGap(117)
																		.addComponent(
																				btnLogo,
																				GroupLayout.PREFERRED_SIZE,
																				126,
																				GroupLayout.PREFERRED_SIZE)))
										.addContainerGap(108, Short.MAX_VALUE)));
		panelTransparan.setLayout(panelTransparan2Layout);

		panelBackground.add(panelTransparan, java.awt.BorderLayout.CENTER);
		getContentPane().add(panelBackground, java.awt.BorderLayout.CENTER);

		pack();
	}// </editor-fold>//GEN-END:initComponents

	private void btnExitActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_buttonTransparan4ActionPerformed
		if (showConfirm("Anda Yakin?") != JOptionPane.OK_OPTION) {
			return;
		}
		System.exit(0);
	}

	private int showConfirm(String message) {
		return JOptionPane.showConfirmDialog(this, message, "Konfirmasi",
				JOptionPane.OK_CANCEL_OPTION);
	}
}
